//render是渲染进程
console.log('index里的22222render.js')

const btn1 = document.getElementById('btn1')
const btn2 = document.getElementById('btn2')
const btn3 = document.getElementById('btn3')
const input = document.getElementById('input')

btn1.onclick = ()=>{
    alert(myAPI.version)
}

btn2.onclick = ()=>{
    myAPI.saveFile(input.value)
    alert('写入成功')
    // 清空输入框以便下一次输入
    input.value = ''
}

btn3.onclick = async ()=>{
    try {
        const res = await myAPI.readFile();
        alert(res);
    } catch (error) {
        console.error('读取文件时出错:', error);
        alert('读取文件失败');
    }
}